package com.executor.future;

import com.sunfeng.TimeUtils;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicLong;

/**
 * @Author : 孙峰
 * @Description:
 * @Date : 2022/10/6  15:21
 */
public class Demo00 {

    private static ExecutorService executorService = Executors.newSingleThreadExecutor();

    public static void main(String[] args) throws ExecutionException, InterruptedException {


        AtomicLong atomicLong = new AtomicLong();
        Future<AtomicLong> future = executorService.submit(() -> {

            TimeUtils.sleep(10);
            atomicLong.set(3500L);

        }, atomicLong);
        TimeUtils.sleep(5);



        System.out.println("The task result: " + future.get());

        executorService.shutdown();
    }
}
